package com.linkhub.oms.data.sync.api.shopify.domain.response;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

import java.io.Serializable;
import java.util.List;

/**
 * @author Jaycle
 * @version 1.0.0
 * @description ShopShippingNameResponse
 * @date 2024/05/08日 20:24
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class ShopShippingNameResponse extends BaseResponse implements Serializable {
    @Override
    @JSONField(serialize = false, deserialize = false)
    public boolean success() {
        return true;
    }

    @Override
    public int count() {
        return 0;
    }

    @Override
    public String maxUpdateTime() {
        return null;
    }

    @JSONField(name = "shipping_zones")
    private List<ShippingZones> shippingZonesList;

    @NoArgsConstructor
    @Data
    public static class ShippingZones {
        private long id;
        private String name;
        @JsonProperty("profile_id")
        private String profileId;
        @JsonProperty("location_group_id")
        private String locationGroupId;
        @JsonProperty("admin_graphql_api_id")
        private String adminGraphqlApiId;
        private List<Country> countries;
        @JsonProperty("weight_based_shipping_rates")
        private List<WeightBasedShippingRate> weightBasedShippingRates;
        @JsonProperty("price_based_shipping_rates")
        private List<PriceBasedShippingRate> priceBasedShippingRates;
        @JsonProperty("carrier_shipping_rate_providers")
        private List<String> carrierShippingRateProviders;
    }

    @NoArgsConstructor
    @Data
    public static class Country {
        private long id;
        private String name;
        private double tax;
        private String code;
        @JsonProperty("tax_name")
        private String taxName;
        @JsonProperty("shipping_zone_id")
        private long shippingZoneId;
        private List<Province> provinces;

        public long getId() {
            return id;
        }

        public void setId(long id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public double getTax() {
            return tax;
        }

        public void setTax(double tax) {
            this.tax = tax;
        }

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getTaxName() {
            return taxName;
        }

        public void setTaxName(String taxName) {
            this.taxName = taxName;
        }

        public long getShippingZoneId() {
            return shippingZoneId;
        }

        public void setShippingZoneId(long shippingZoneId) {
            this.shippingZoneId = shippingZoneId;
        }

        public List<Province> getProvinces() {
            return provinces;
        }

        public void setProvinces(List<Province> provinces) {
            this.provinces = provinces;
        }

        // Getter and setter methods
    }

    @NoArgsConstructor
    @Data
    public static class Province {
        private long id;
        @JsonProperty("country_id")
        private long countryId;
        private String name;
        private String code;
        private double tax;
        @JsonProperty("tax_name")
        private String taxName;
        @JsonProperty("tax_type")
        private String taxType;
        @JsonProperty("tax_percentage")
        private double taxPercentage;
        @JsonProperty("shipping_zone_id")
        private long shippingZoneId;

        // Getter and setter methods
    }

    @NoArgsConstructor
    @Data
    public static class WeightBasedShippingRate {
        private long id;
        private String name;
        private String price;
        @JsonProperty("shipping_zone_id")
        private long shippingZoneId;
        @JsonProperty("weight_low")
        private double weightLow;
        @JsonProperty("weight_high")
        private double weightHigh;

        // Getter and setter methods
    }

    @NoArgsConstructor
    @Data
    public static class PriceBasedShippingRate {
        private long id;
        private String name;
        private String price;
        @JsonProperty("shipping_zone_id")
        private long shippingZoneId;

        // Getter and setter methods
    }

    public static void main(String[] args) {
        String json = "{\n" +
                "    \"shipping_zones\": [{\n" +
                "            \"id\": 301549125686,\n" +
                "            \"name\": \"Domestic\",\n" +
                "            \"profile_id\": \"gid://shopify/DeliveryProfile/81462296630\",\n" +
                "            \"location_group_id\": \"gid://shopify/DeliveryLocationGroup/82201083958\",\n" +
                "            \"admin_graphql_api_id\": \"gid://shopify/DeliveryZone/301549125686\",\n" +
                "            \"countries\": [{\n" +
                "                    \"id\": 452734451766,\n" +
                "                    \"name\": \"China\",\n" +
                "                    \"tax\": 0.13,\n" +
                "                    \"code\": \"CN\",\n" +
                "                    \"tax_name\": \"VAT\",\n" +
                "                    \"shipping_zone_id\": 301549125686,\n" +
                "                    \"provinces\": [{\n" +
                "                            \"id\": 4785543839798,\n" +
                "                            \"country_id\": 452734451766,\n" +
                "                            \"name\": \"Anhui\",\n" +
                "                            \"code\": \"AH\",\n" +
                "                            \"tax\": 0.0,\n" +
                "                            \"tax_name\": \"Tax\",\n" +
                "                            \"tax_type\": null,\n" +
                "                            \"tax_percentage\": 0.0,\n" +
                "                            \"shipping_zone_id\": 301549125686\n" +
                "                        }\n" +
                "                    ]\n" +
                "                }\n" +
                "            ],\n" +
                "            \"weight_based_shipping_rates\": [{\n" +
                "                    \"id\": 473858637878,\n" +
                "                    \"name\": \"Standard\",\n" +
                "                    \"price\": \"4.95\",\n" +
                "                    \"shipping_zone_id\": 301549125686,\n" +
                "                    \"weight_low\": 0.0,\n" +
                "                    \"weight_high\": 5.0\n" +
                "                }, {\n" +
                "                    \"id\": 473858670646,\n" +
                "                    \"name\": \"Heavy Goods Shipping\",\n" +
                "                    \"price\": \"7.50\",\n" +
                "                    \"shipping_zone_id\": 301549125686,\n" +
                "                    \"weight_low\": 5.0001,\n" +
                "                    \"weight_high\": 25.0\n" +
                "                }\n" +
                "            ],\n" +
                "            \"price_based_shipping_rates\": [],\n" +
                "            \"carrier_shipping_rate_providers\": []\n" +
                "        }\n" +
                "    ]\n" +
                "}";
        ShopShippingNameResponse shippingZone = JSON.parseObject(json, ShopShippingNameResponse.class);
        System.out.println(shippingZone);
    }
}

